/**
 *
 * 
 * @param {请求参数方式} type
 * @param {地址} url
 * @param {参数} datas
 * 如果是get请求方式要保证传参顺序，使用数组穿参。
 * @param {回掉函数} successFunction
 */

var httpId = 'http://app.api.test.chipparking.com/';
function ajaxJson(type, url, datas, successFunction, errorFunction) {
	var headers = {
		"Content-Type": "application/json",
		"Accept": "application/json; charset=utf-8"
	};
	//
	var requestUrl = httpId + url;
	//			//如果是get传参需要转换成url字符串。
	if(Array.isArray(datas)) {
		if(datas) {
			for(var index = 0; index < datas.length; index++) {
				var element = datas[index];
				requestUrl += '/' + element;
			}
		} else {}
		datas = {};
	};
	if(type == "post" || type == "POST") {

		datas = JSON.stringify(datas);

	}
	console.log(requestUrl)
	console.log(datas)

	if(url == "app/picCode/queryCar") {
		$(".repeat_shadow").show()

	}

	$.ajax({
		headers: headers,
		type: type,
		url: requestUrl,
		data: datas,
		success: function(data) {

			console.log(data)
			successFunction(data)

		},
		error: function(data) {
			console.log(data)
			errorFunction();

		},
		complete: function() {
			$(".repeat_shadow").hide()

		},
	});

}